package com.cuit.job;

import com.cuit.factory.SingleFactory;
import com.cuit.limit.FlowController;
import com.cuit.limit.ServiceFlowManager;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ClearFlowJob implements Job{

    @Override
    public void doJob() {
        ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
        ServiceFlowManager serviceFlowManager = SingleFactory.getSingle(ServiceFlowManager.class);
        scheduledExecutorService.scheduleAtFixedRate(() -> {
            serviceFlowManager.clearNextMinuteCallCount();
        }, 3, 45, TimeUnit.SECONDS);
    }

}
